package com.learn.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;

@Configuration
public class ConfigBean {

	@Bean
	@LoadBalanced//开启负载均衡，spring cloud Ribbon是基于Netflix Ribbon实现得一套客户端的负载均衡工具
	public RestTemplate getRestTemplate(){
		return new RestTemplate();
	}
	
	//@Bean//不显示声明的话默认使用轮询算法，显示声明的话使用显示声明的算法
	public IRule myRule(){
		return new RandomRule();//随机
	}
}
